package com.ganinfo.common.aliyun;



import com.ganinfo.common.Logger;
import com.ganinfo.common.constant.PropertiesConstant;

public class AliOSSInitConfig {
	protected Logger logger = Logger.getLogger(this.getClass());
	/**
	 * 配置阿里云服务
	 * @author k
	 */
	public void initAliOssService(){
		logger.info("建立阿里OSS服务连接:");
		String key = PropertiesConstant.CONFIG_PRO.getStr("aliosskey");
		String secret = PropertiesConstant.CONFIG_PRO.getStr("aliosssecret");
		String endpoint= PropertiesConstant.CONFIG_PRO.getStr("aliossendpoint");
		String defaultbucket= PropertiesConstant.CONFIG_PRO.getStr("defaultbucket");
		String innerendpoint= PropertiesConstant.CONFIG_PRO.getStr("aliossendpointinternal");
		String isinserver=PropertiesConstant.CONFIG_PRO.getStr("isinserver");
		boolean isinECS=false;
		if("true".equals(isinserver)){
			isinECS=true;
		}
		try {
			boolean flag=AliOSSTool.init(key, secret, endpoint, defaultbucket,innerendpoint,isinECS);
			logger.info("连接阿里OSS服务："+(flag?"成功":"失败"));
		} catch (Exception e) {
			e.printStackTrace();
			logger.info(String.format("连接阿里OSS服务出错：%1$s.", e.getMessage()));
		}
	}

}
